{% load taxonomy %}

{% if children %}
<ul>
    {% for child in children %}
        {% ifequal child active %}
            <li class="taxonomy-active">
        {% else %}
            <li>
        {% endif %}
            {% if render_models %}
                {% if child.instances %}
                    {% for instance in child.instances %}
                        {% if forloop.first and forloop.last %}
                            <a title='{{child.description}}' href='{{instance.data.url}}'>{{child.name}}</a>
                            {% if render_counts %}
                                (1)
                            {% endif %}
                        {% else %}
                            {% if forloop.last %}
                                <a title='{{child.description}}' href='{{child.term.get_absolute_path}}'>{{child.name}}</a>
                            {% endif %}
                            {% if term.display_children_counts %}
                                ({{child.instances|length}})
                            {% endif %}
                        {% endif %}
                    {% endfor %}
                {% else %}
                    <a title='{{child.description}}' href='{{child.term.get_absolute_path}}'>{{child.name}}</a>
                {% endif %}
            {% else %}
                <a title='{{child.description}}' href='{{child.term.get_absolute_path}}'>{{child.name}}</a>
            {% endif %}
            {% if child.children %}
                {% taxonomy_render_list child.term %}
            {% endif %}
        </li>
    {% endfor %}
</ul>
{% endif %}

